<?php //debug($norden);        ?>
<?php $cantidad = $orden['Ordene']['ordenescambio']; ?>
<?php $codOrden = $orden['Ordene']['id']; ?>
<?php //$numero = $norden['Cambiordene']['numero'];     ?>
<?php echo $this->Form->create('Cambiosorden', array('id' => "validate")); ?>
<?php
/* echo $this->Ajax->form(array('type' => 'post',
  'options' => array(
  'model' => 'Cambiosorden',
  'update' => "ordenesa/$codOrden",
  'url' => array(
  'controller' => 'Ordenes',
  'action' => 'corden'
  ),
  )
  )); */
?>
<!-- Collapsible. Closed by default -->
<?php //echo $this->element($name) ?>
<div class="widget grid12">
    <div class="whead"><h6>FORMULARIO DE CAMBIO DE ORDEN</h6><div class="clear"></div></div>
    <table>
        <tbody>
            <tr>
                <th>NOMBRE</th>
                <td><?php echo $orden['Ordene']['nombre']; ?></td>
            </tr>
            <tr>
                <th>CATEGORIA</th>
                <td><?php echo $orden['Categoria']['nombre']; ?></td>
            </tr>
        </tbody>
    </table>    
    <?php if($cambiosO): ?>
   <?php foreach($cambiosO as $c): ?>
    <table cellpadding="0" cellspacing="0" width="100%" class="tAlt">
        <tr>
            <td>Cambio de Orden</td>
            <td><h3>000<?php echo $c['Cambiordene']['numero']; ?></h3></td>
            <td>Monto</td>
            <td><?php echo $c['Cambiordene']['monto']; ?></td>
        </tr>
        <tr>
            <td>Volumen</td>
            <td>
            <?php 
                if(empty($c['Cambiordene']['volumen'])){
                    echo 'NO TIENE';    
                }else{
                 echo $c['Cambiordene']['volumen']; 
                }                    
                
            ?></td>
            <td>Fecha</td>
            <td><?php echo $c['Cambiordene']['fecha']; ?></td>
        </tr>
    </table>
    <div class="clear"></div>
    <p>&nbsp;</p>
    <?php endforeach; ?>
    <?php else: ?>
        No tiene CO
    <?php endif; ?>
    <?php //$sig = $numero + 1;  ?>
    <div class="widget fluid">
        <div class="whead"><h6>CAMBIO DE ORDEN No. <?php echo $orden['Ordene']['nombre']; ?></h6><div class="clear"></div></div>   
        <div class="clear"></div>              
        <div class="formRow"> 
            <div class="grid3"><label>Fecha :</label></div>
            <div class="grid9">
                <?php echo $this->Form->hidden("Cambiordene.ordene_id", array('value' => $codOrden)); ?>
                <?php //echo $this->Form->hidden("Cambiordene.numero", array('value' => "$sig")); ?>
                <?php echo $this->Form->text("Cambiordene.fecha", array('placeholder' => 'Ingrese Fecha a-m-d Ej: 2012-23-04', 'id' => "fecha")); ?>
            </div>
            <div class="clear"></div>
        </div>

        <div class="formRow"> 
            <div class="grid3"><label>Numero CO :</label></div>
            <div class="grid9">
                <?php echo $this->Form->text("Cambiordene.numero", array('placeholder' => 'Ingrese numero Ej: 2', "class" => "validate[required]")); ?>            
            </div>
            <div class="clear"></div>
        </div>

        <div class="formRow"> 
            <div class="grid3"><label>Volumen :</label></div>
            <div class="grid9">
                <?php echo $this->Form->text("Cambiordene.volumen", array('placeholder' => 'Ingrese volumen Ej: 2', "class" => "validate[required]")); ?>            
            </div>
            <div class="clear"></div>
        </div>

        <div class="formRow">
            <div class="grid3"><label>Original :</label></div>
            <div class="grid3">            
                <?php echo $this->Form->checkbox("Cambiordene.original", array('value' => '1', 'hiddenField' => '0')); ?>
            </div>

            <div class="grid3"><label>Cant Firmas :</label></div>
            <div class="grid3">            
                <?php echo $this->Form->text('Cambiordene.cantforiginal', array('placeholder' => '0')); ?>
                <?php //echo $this->Form->checkbox("tagSel", array('value' => 1, 'hiddenField' => false));  ?>
            </div>
            <div class="clear"></div>
        </div>

        <div class="formRow">
            <div class="grid3"><label>Copia: </label></div>
            <div class="grid3">
                <?php echo $this->Form->checkbox("Cambiordene.copia", array('value' => "1", 'hiddenField' => '0')); ?>
            </div>
            <div class="grid3"><label>Cant. Firmas :</label></div>
            <div class="grid3">
                <?php echo $this->Form->text('Cambiordene.cantfcopia', array('placeholder' => '0')); ?>
            </div>        
            <div class="clear"></div>
        </div>

        <div class="formRow"> 
            <div class="grid3"><label>Monto : </label></div>
            <div class="grid9">
                <?php echo $this->Form->text("Cambiordene.monto", array('placeholder' => 'Ingrese numero Ej: 2', "class" => "validate[required]")); ?>            
            </div>
            <div class="clear"></div>
        </div>

        <div class="formRow"> 
            <div class="grid3"><label>Observaciones :</label></div>
            <div class="grid9">
                <?php echo $this->Form->text("Cambiordene.observaciones", array('placeholder' => 'Ingrese Ovservaciones')); ?>            
            </div>
            <div class="clear"></div>
        </div>

        <!-- sheepIt Form -->
        <div id="sheepItForm">
            <!-- Form template-->
            <div id="sheepItForm_template">
                <div class="formRow">
                    <div class="grid2"><label><span id="sheepItForm_label"></span>.- Tag :</label></div>
                    <div class="grid2 moreFields allUpper">
                        <?php echo $this->Form->text('CambiordenesTag.#index#.tag', array('placeholder' => '')); ?>
                    </div>
                    <div class="grid2"><label>Numero Activo :</label></div>
                    <div class="grid2">
                        <?php echo $this->Form->text('CambiordenesTag.#index#.nactivo', array('placeholder' => '')); ?>
                    </div>
                    <div class="grid2"><label>Monto :</label></div>
                    <div class="grid2">
                        <?php echo $this->Form->text('CambiordenesTag.#index#.monto'); ?>
                        <a id="sheepItForm_remove_current" style="float: left">
                            X
                        </a>
                    </div>
                    <div class="clear"></div>                 
                </div>
            </div>   
            <!-- /Form template-->                  
            <!-- No forms template -->
            <div id="sheepItForm_noforms_template">Ningun Tags</div>
            <!-- /No forms template-->
            <!-- Controls -->
       <div id="sheepItForm_controls">
            <div id="sheepItForm_add"><a class="buttonS bGreen"><span>(+)Mas Tags</span></a></div>
            <p></p>
            <div id="sheepItForm_remove_last"><a class="buttonS bRed"><span>(-)Quitar</span></a></div>
            <div id="sheepItForm_remove_all"><a class="buttonS bRed"><span>(-)Quitar Todos</span></a></div>
            <div id="sheepItForm_add_n">
                <input id="sheepItForm_add_n_input" type="text" size="4" style="border: 1px solid #006;"/>
                <p></p>
                <div id="sheepItForm_add_n_button"><a class="buttonS bGold"><span>Anadir</span></a></div></div>
        </div>
            <!-- /Controls -->

        </div>
        <!-- /sheepIt Form -->          

    
        
    </div>
</div>
<script>
    $(document).ready(function() { 
        
        $( "#fecha" ).datepicker({
            defaultDate: +7,
            showOtherMonths:true,
            autoSize: true,
            /*appendText: '(Ano-Mes-Dia)',*/
            dateFormat: 'yy-mm-dd',
            changeMonth: true,
            changeYear: true
        }); 
        
        var sheepItForm = $('#sheepItForm').sheepIt({
            separator: '',
            allowRemoveLast: true,
            allowRemoveCurrent: true,
            allowRemoveAll: true,
            allowAdd: true,
            allowAddN: true,
            maxFormsCount: 150,
            minFormsCount: 1,
            iniFormsCount: 1,
            continuousIndex: true
        });              
            
    } );                     
</script>
<p></p>
<div class="actions-right">
            <?php
            $options = array(
                'label' => 'Guardar Datos',
                'class' => 'buttonS bLightBlue',
                'id' => 'btEnvia'
            );
            echo $this->Form->end($options);
            ?> 
            <p></p>    
            <?php echo $this->Html->link('NUEVA ORDEN', array('action' => 'insertar'), array('class'=>'buttonS bGreen ')); ?>
</div>